package java8;

import org.junit.Test;

import java.time.Duration;
import java.time.Instant;
import java.util.stream.LongStream;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/7/19 21:56
 */
public class TestForkJoin {
    @Test
    public void test() {
        Instant start = Instant.now();
        Long result = LongStream.rangeClosed(0, 100000000L)
                .parallel()
                .reduce(0, Long::sum);
        Instant end = Instant.now();
        System.out.println("result:" + result);
        System.out.println("consume time:" + Duration.between(start, end).toMillis());
    }
}
